﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Aribaccio;
using BDPAutodetect.Device;
using CommunityToolkit.Mvvm.ComponentModel;

namespace BDPAutodetect.Models
{
    /// <summary>
    /// 指标视图模型数据
    /// </summary>
    public partial class MTarget : MBasic
    {
        /// <summary>
        /// 序号
        /// </summary>
        [ObservableProperty]
        protected int serialNo;

        /// <summary>
        /// 指标类型
        /// </summary>
        [ObservableProperty]
        protected DeviceTargetType targetType;

        /// <summary>
        /// 指标种类
        /// </summary>
        [ObservableProperty]
        protected DeviceType targetCategory;

        /// <summary>
        /// 指标种类数据
        /// </summary>
        [ObservableProperty]
        protected DeviceTypeData? targetCategoryData;

        /// <summary>
        /// 构造函数
        /// </summary>
        public MTarget()
        {
            this.TargetType = DeviceTargetType.None;
            this.TargetCategory = DeviceType.None;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        public MTarget(int argID, string argCode, string argName) : base()
        {
            this.ID = argID;
            this.Code = argCode;
            this.Name = argName;
            this.TargetType = DeviceTargetType.None;
            this.TargetCategory = DeviceType.None;
        }

        /// <summary>
        /// 深度克隆
        /// </summary>
        /// <returns></returns>
        public override MTarget CloneDeep()
        {
            return new MTarget(this.ID, this.Code, this.Name)
            {
                SerialNo = this.SerialNo,
                TargetType = this.TargetType,
                TargetCategory = this.TargetCategory,
                TargetCategoryData = this.TargetCategoryData
            };
        }

        /// <summary>
        /// 克隆数据表
        /// </summary>
        /// <returns></returns>
        public TBasicTarget CloneTData()
        {
            return new TBasicTarget()
            {
                ID = this.ID,
                Code = this.Code,
                Name = this.Name,
                Category = this.TargetCategory.ToInt()
            };
        }

    }
}
